/**
 * Represent a Vector in 2d.
 * @authors Itay Sorani, Nadav Ziv, Yonathan Zarsky
 */
package com.example.util;

public class Vec2D {
	
	private float x;
	private float y;
	
	public Vec2D (float x, float y)
	{
		setVec(x, y);
	}
	
	public void setX(float x) {
		this.x = x;
	}
	public float getX() {
		return (this.x);
	}
	/**
	 * @param y the y to set
	 */
	public void setY(float y) {
		this.y = y;
	}
	/**
	 * @return the y
	 */
	public float getY() {
		return (this.y);
	}
	
	public void setVec (float x, float y)
	{
		this.x = x;
		this.y = y;
	}
	
	public double getDist (Vec2D vec) {
		return ( Math.sqrt((Math.pow(this.x - vec.getX(), 2)) + (Math.pow(this.y - vec.getY(), 2))) );
	}
	
	public void normalize() {
		float sqrt = (float)(Math.sqrt((x * x) + (y * y)));
		this.x = x / sqrt;
		this.y = y / sqrt;
	}
}
